//
//  SettingsController.m
//  吃货·上海
//
//  Created by 濮亚军 on 15/11/26.
//  Copyright © 2015年 濮亚军. All rights reserved.
//

#import "SettingsController.h"
#import "MyInfoViewController.h"

@interface SettingsController ()

@property (nonatomic,strong)UIButton *myInfoBtn;
@property (nonatomic,strong)UIButton *clearBtn;


@end

@implementation SettingsController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    self.view.backgroundColor = [UIColor grayColor];
    
    // 个人中心
    self.myInfoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.myInfoBtn.frame = CGRectMake((KScreenWidth - 120)/2, KScreenHeight/4, 120, 30);
    self.myInfoBtn.backgroundColor = [UIColor greenColor];
    [self.myInfoBtn setTitle:@"个人中心" forState:UIControlStateNormal];
    self.myInfoBtn.layer.cornerRadius = 10;
    [self.myInfoBtn addTarget:self action:@selector(myInfoBtn:) forControlEvents:UIControlEventTouchUpInside];
    [self.myInfoBtn.layer setMasksToBounds:YES];
    [self.view addSubview:self.myInfoBtn];
    
    // 清除缓存
    self.clearBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.clearBtn.frame = CGRectMake((KScreenWidth - 120)/2, KScreenHeight/3, 120, 30);
    self.clearBtn.backgroundColor = [UIColor greenColor];
    [self.clearBtn addTarget:self action:@selector(clearBtn:) forControlEvents:UIControlEventTouchUpInside];
    [self.clearBtn setTitle:@"清除缓存" forState:UIControlStateNormal];
    self.clearBtn.layer.cornerRadius = 10;
    [self.clearBtn.layer setMasksToBounds:YES];
    [self.view addSubview:self.clearBtn];
    
    
}

// 清除缓存
- (void)clearBtn:(UIButton *)btn
{
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, 30)];
    label.center = self.view.center;
    label.text = @"缓存已清除";
    label.font = [UIFont boldSystemFontOfSize:18];
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [UIColor greenColor];
    label.alpha = 0;
    [self.view addSubview:label];
    
    [UIView animateWithDuration:1 animations:^{
        label.alpha = 1;
    } completion:^(BOOL finished) {
        if (finished) {
            [UIView animateWithDuration:1 animations:^{
                label.alpha = 0;
            }];
        }
    }];
    
}


// 个人中心
- (void)myInfoBtn:(UIButton *)button
{
    MyInfoViewController *myInfoVc = [[MyInfoViewController alloc]init];
    //myInfoVc.mineModel = self.model;
    [self.navigationController pushViewController:myInfoVc animated:NO];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
